/**
 * Copyright (c) 2009 Teoti Graphix, LLC See:
 *     http://tkarchitecture.teotigraphix.org
 * 
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following
 * conditions:
 * 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 * 
 * @author Michael Schmalle mschmalle@teotigraphix.com
 */
package org.teotigraphix.dx.patterns.manager.meta
{

/**
 * @private
 * 
 * The data object that holds arrays of metadata info objects.
 * 
 * <p><em>This class is internal to the toolkit.</em></p>
 * 
 * @author Michael Schmalle
 * @copyright Teoti Graphix, LLC
 * @date 12-04-08
 */
public final class ClassMetaData
{
	include "../../../core/Version.as"
	
	//--------------------------------------------------------------------------
	//
	//  Public :: Variables
	//
	//--------------------------------------------------------------------------

	/**
	 * The class's skin parts.
	 * 
	 * @see SkinPartAliasInfo
	 */
	public var componentAliases:Array = [];

	/**
	 * The class's skin parts.
	 * 
	 * @see SkinPartAliasInfo
	 */
	public var skinPartAliases:Array = [];

	/**
	 * The class's .
	 * 
	 * @see ModelAliasInfo
	 */
	public var modelAliases:Array = [];
	
	/**
	 * The class's style bindings.
	 * 
	 * @see StyleBindingInfo
	 */
	public var styleBindings:Array = [];
	
	/**
	 * The class's service bindings.
	 * 
	 * @see ModelBindingInfo
	 */
	public var modelBindings:Array = [];
		
	/**
	 * The class's event handlers.
	 * 
	 * @see ComponentHandlerInfo
	 */
	public var componentHandlers:Array = [];
	
	/**
	 * The class's model handlers.
	 * 
	 * @see ModelHandlerInfo
	 */
	public var modelHandlers:Array = [];
	
	/**
	 * The class's skin handlers.
	 * 
	 * @see SkinHandlerInfo
	 */
	public var skinHandlers:Array = [];

	/**
	 * The class's event handlers.
	 * 
	 * @see SkinPartHandlerInfo
	 */
	public var skinPartHandlers:Array = [];
	
	//----------------------------------
	//  Halo
	//----------------------------------
	
	/**
	 * The class's skin parts.
	 * 
	 * @see SkinPartInfo
	 */
	public var skinParts:Array = [];

	/**
	 * The class's skin states.
	 * 
	 * @see SkinStateInfo
	 */
	public var skinStates:Array = [];
	
	//--------------------------------------------------------------------------
	//
	//  Public :: Methods
	//
	//--------------------------------------------------------------------------
	
	/**
	 * Returns a <code>ComponentAliasInfo</code> by id.
	 * 
	 * @param id A string indicating the name of the [ComponentAlias] to return.
	 */
	public function getComponentAliasByID(id:String):ComponentAliasInfo
	{
		var len:int = componentAliases.length;
		for (var i:int = 0; i < len; i++)
		{
			if (componentAliases[i].id == id)
				return componentAliases[i];
		}
		return null;
	}
	
	/**
	 * Returns a <code>SkinPartAliasInfo</code> by id.
	 * 
	 * @param id A string indicating the name of the [SkinPartAlias] to return.
	 */
	public function getSkinPartAliasInfoByID(id:String):SkinPartAliasInfo
	{
		var len:int = skinPartAliases.length;
		for (var i:int = 0; i < len; i++)
		{
			if (skinPartAliases[i].id == id)
				return skinPartAliases[i];
		}
		return null;
	}	
	
	/**
	 * Returns a <code>ModelAliasInfo</code> by id.
	 * 
	 * @param type A string indicating the type of the [ModelAlias] to return.
	 */
	public function getModelAliasByType(type:String):ModelAliasInfo
	{
		var len:int = modelAliases.length;
		for (var i:int = 0; i < len; i++)
		{
			if (modelAliases[i].type == type)
				return modelAliases[i];
		}
		return null;
	}
	
	/**
	 * Returns a <code>ModelAliasInfo</code> by id.
	 * 
	 * @param id A string indicating the name of the [ModelAlias] to return.
	 */
	public function getModelAliasByID(id:String):ModelAliasInfo
	{
		var len:int = modelAliases.length;
		for (var i:int = 0; i < len; i++)
		{
			if (modelAliases[i].id == id)
				return modelAliases[i];
		}
		return null;
	}
	
	/**
	 * Returns a <code>ComponentHandlerInfo</code> by event.
	 * 
	 * @param event A string indicating the name of the [ComponentHandler] to return.
	 */
	public function getComponentHandlerByEvent(event:String):ComponentHandlerInfo
	{
		var len:int = componentHandlers.length;
		for (var i:int = 0; i < len; i++)
		{
			if (componentHandlers[i].event == event)
				return componentHandlers[i];
		}
		return null;
	}
	
	/**
	 * Returns a <code>SkinHandlerInfo</code> by event.
	 * 
	 * @param event A string indicating the name of the [SkinHandler] to return.
	 */
	public function getSkinHandlerByEvent(event:String):SkinHandlerInfo
	{
		var len:int = skinHandlers.length;
		for (var i:int = 0; i < len; i++)
		{
			if (skinHandlers[i].event == event)
				return skinHandlers[i];
		}
		return null;
	}
	
	/**
	 * Returns a <code>SkinPartHandlerInfo</code> by event.
	 * 
	 * @param event A string indicating the name of the [SkinPartHandler] to return.
	 */
	public function getSkinPartHandlerInfoByEvent(event:String):SkinPartHandlerInfo
	{
		var len:int = skinPartHandlers.length;
		for (var i:int = 0; i < len; i++)
		{
			if (skinPartHandlers[i].event == event)
				return skinPartHandlers[i];
		}
		return null;
	}	
	
	/**
	 * Returns a <code>StyleBindingInfo</code> by name.
	 * 
	 * @param id A string indicating the name of the [StyleBinding] to return.
	 */
	public function getStyleBindingByName(id:String):StyleBindingInfo
	{
		var len:int = styleBindings.length;
		for (var i:int = 0; i < len; i++)
		{
			if (styleBindings[i].id == id)
				return styleBindings[i];
		}
		return null;
	}
	
	/**
	 * Returns a <code>ModelBindingInfo</code> by name.
	 * 
	 * @param id A string indicating the name of the [ModelBinding] to return.
	 */
	public function getModelBindingByID(id:String):ModelBindingInfo
	{
		var len:int = modelBindings.length;
		for (var i:int = 0; i < len; i++)
		{
			if (modelBindings[i].id == id)
				return modelBindings[i];
		}
		return null;
	}
	
	/**
	 * Returns a <code>ModelHandlerInfo</code> by name.
	 * 
	 * @param event A string indicating the name of the [ModelHandler] to return.
	 */
	public function getModelHandlerByEvent(event:String):ModelHandlerInfo
	{
		var len:int = modelHandlers.length;
		for (var i:int = 0; i < len; i++)
		{
			if (modelHandlers[i].event == event)
				return modelHandlers[i];
		}
		return null;
	}
	
	//----------------------------------
	//  Halo
	//----------------------------------
	
	/**
	 * Returns a <code>SkinPartInfo</code> by id.
	 * 
	 * @param id A string indicating the name of the [SkinPart] to return.
	 */
	public function getSkinPartInfoByID(id:String):SkinPartInfo
	{
		var len:int = skinParts.length;
		for (var i:int = 0; i < len; i++)
		{
			if (skinParts[i].id == id)
				return skinParts[i];
		}
		return null;
	}
	
	/**
	 * Returns a <code>SkinStateInfo</code> by id.
	 * 
	 * @param id A string indicating the name of the [SkinState] to return.
	 */
	public function getSkinStateInfoByID(id:String):SkinStateInfo
	{
		var len:int = skinStates.length;
		for (var i:int = 0; i < len; i++)
		{
			if (skinStates[i].id == id)
				return skinStates[i];
		}
		return null;
	}	
}
}